home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Other Langs
/
mpw yacc ƒ src
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-11-19
|
2KB
|
158 lines
#include <stdio.h>
#include <signal.h>
#include "dep.h"
#include "defs.h"
#include "files.h"
#include "state.h"
#include "symtab.h"
#include "tokens.h"
extern tidy();
extern aborted();
char dflag;
char lflag;
char tflag;
char vflag;
char *prefix = "y";
char *myname = "yacc";
int lineno;
YYSTYPE yylval;
usage()
{
fprintf(stderr, "usage: %s [-dltv] [-b prefix] filename\n", myname);
exit(1);
}
getargs(argc, argv)
int argc;
char *argv[];
{
register int i;
register char *s;
if (argc > 0) myname = argv[0];
for (i = 1; i < argc; ++i)
{
s = argv[i];
if (*s != '-') break;
switch (*++s)
{
case '\0':
input_file = stdin;
if (i + 1 < argc) usage();
return;
case '_':
++i;
goto no_more_options;
case 'b':
if (*++s || ++i >= argc) usage();
prefix = argv[i];
continue;
case 'd':
dflag = 1;
break;
case 'l':
lflag = 1;
break;
case 't':
tflag = 1;
break;
case 'v':
vflag = 1;
break;
default:
usage();
}
for (;;)
{
switch (*++s)
{
case '\0':
goto end_of_option;
case 'd':
dflag = 1;
break;
case 'l':
lflag = 1;
break;
case 't':
tflag = 1;
break;
case 'v':
vflag = 1;
break;
default:
usage();
}
}
end_of_option:;
}
no_more_options:;
if (i + 1 < argc) usage();
input_file_name = argv[i];
}
int
main(argc, argv)
int argc;
char *argv[];
{
register int c;
(void) signal(SIGINT, aborted);
#ifdef MACINTOSH
parser_file_name = argv[0];
#ifdef AZTECC
defSpin(0x20);
#endif
#endif
getargs(argc, argv);
openfiles();
tabinit();
initialize_lex();
reader();
set_derives();
set_nullable();
generate_states();
optim();
lalr();
make_parser();
initialize_conflicts();
if (vflag)
verbose();
output();
fclose(action_file);
action_file = fopen(action_file_name, "r");
c = getc(action_file);
while (c != EOF)
{
putc(c, output_file);
c = getc(action_file);
}
tidy();
}